﻿using CommonServiceLocator;
using GalaSoft.MvvmLight;
using Jn698._45GWTool.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Jn698._45GWTool.Settings
{
    internal class TerminalSettings : ConfigurationSection,INotifyPropertyChanged
    {
        public static TerminalSettings Instanse { get; } = App.Current.Cfg.GetSection("terminalSettings") as TerminalSettings;
        [ConfigurationProperty("LogicAddressSelected", DefaultValue = 0)]
        public int LogicAddressSelected
        {
            get => (int)this["LogicAddressSelected"];
            set
            {
                this["LogicAddressSelected"] = value;
                
            }
        }

        [ConfigurationProperty("TimeTagFlag", DefaultValue = false)]
        public bool TimeTagFlag
        {
            get => (bool)this["TimeTagFlag"];
            set
            {
                this["TimeTagFlag"] = value;

            }
        }

        [ConfigurationProperty("TimeTagData", DefaultValue = "010005")]
        public string TimeTagData
        {
            get => (string)this["TimeTagData"];
            set
            {
                this["TimeTagData"] = value;
                OnChanged(new PropertyChangedEventArgs("TimeTagData"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnChanged(PropertyChangedEventArgs arg)//具体方法
        {
            PropertyChanged?.Invoke(this, arg);
        }
    }
}
